package org.firefly.fx.service.user.impl;

import org.firefly.fx.service.common.IReceiveService;
import org.firefly.fx.service.common.IWebsocketSessionService;
import org.firefly.fx.util.JSonUtil;
import org.firefly.fx.vo.RouteMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("receive.service.demo")
public class ReceiveDemoServiceImpl implements  IReceiveService{
	@Autowired private IWebsocketSessionService wssService;
//	@Autowired private RedisTemplate
	@Override
	public void receive(RouteMessage msg) {
		String realMsg = msg.getParam();
		
		realMsg = msg.getUserId()+":"+realMsg;
		
		RouteMessage rtRouteMsg = new RouteMessage();
		rtRouteMsg.setUserId(msg.getUserId());
		rtRouteMsg.setService("send.service.demo");
		rtRouteMsg.setParam(realMsg);
		
		wssService.sendMsgToUsers(JSonUtil.toJSonString(rtRouteMsg));
	}
	
}
